package com.itheima.manager;

import com.itheima.domain.SmsFlashPromotionProductRelation;
import com.itheima.service.db.SmsFlashPromotionProductRelationService;
import com.itheima.util.R;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ChenTianSui
 * @date 2022/11/13 0:07
 */
@Component
public class SmsProductRelationManager {
    @DubboReference
    private SmsFlashPromotionProductRelationService productRelationService;

    public R<PageBeanVo> findListByPage(Integer flashPromotionId, Integer flashPromotionSessionId, Integer pageNum, Integer papageSize) {
        PageBeanVo pageBeanVo = productRelationService.findListByPage(flashPromotionId, flashPromotionSessionId, pageNum, papageSize);
        return R.success(pageBeanVo);
    }

    public R create(List<SmsFlashPromotionProductRelation> relationList) {
        productRelationService.create(relationList);
        return R.success(1);

    }

    public R delete(Integer id) {
        productRelationService.delete(id);
        return R.success("");
    }

    public R update(Integer id, SmsFlashPromotionProductRelation smsFlashPromotionProductRelation) {
        productRelationService.update(id, smsFlashPromotionProductRelation);
        return R.success("");
    }

    public R<SmsFlashPromotionProductRelation> findById(Integer id) {
        SmsFlashPromotionProductRelation productRelation = productRelationService.findById(id);
        return R.success(productRelation);

    }
}
 
